<template>
  <el-card>
    <div class="bock">
      <div class="state">审核状态：待审核</div>
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        size="mini"
        label-width="100px"
        class="ruleForm"
      >
        <div class="title">
          <span class="icon"></span>
          基本信息
        </div>
        <el-form-item label="用户名" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="人员类型" prop="region">
          <span>个人用户</span>
          <span>企业用户</span>
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <div class="title">
          <span class="icon"></span>
          联系信息
        </div>
        <el-form-item label="手机号" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="所属单位" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="居住地址" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="详细地址" prop="desc">
          <el-input type="textarea" v-model="ruleForm.desc"></el-input>
        </el-form-item>

        <div class="title">
          <span class="icon"></span>
          证件照片
        </div>
        <el-form-item label="身份证" prop="PROCESS_NAME">
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            multiple
            :limit="2"
            list-type="picture"
            :file-list="fileList"
          >
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
        </el-form-item>
        <div class="title">
          <span class="icon"></span>
          单位信息
        </div>
        <el-form-item label="单位名称" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="统一社会信用代码" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="单位地址" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="详细地址" prop="desc">
          <el-input type="textarea" v-model="ruleForm.desc"></el-input>
        </el-form-item>
        <el-form-item label="营业执照" prop="PROCESS_NAME">
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            multiple
            :limit="2"
            list-type="picture"
            :file-list="fileList"
          >
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
        </el-form-item>
        <div class="btn">
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')"
              >保 存</el-button
            >
            <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
          </el-form-item>
        </div>
      </el-form>
    </div>
  </el-card>
</template>
 
<script>
export default {
  name: "GridExample",
  data() {
    return {
      ruleForm: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },

      fileList: [],
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "change" },
        ],

        type: [
          {
            type: "array",
            required: true,
            message: "请至少选择一个活动性质",
            trigger: "change",
          },
        ],

        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }],
      },
    };
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },

    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>
 
<style  scoped>
.bock {
  position: relative;
  padding: 16px;
  /* width: 60%; */
}
.bock .title {
  margin-bottom: 20px;
}
.bock .title .icon {
  width: 4px;
  height: 12px;
  display: inline-block;
  background-color: #3c94f4;
}
.bock .btn {
  position: absolute;
  bottom: 0px;
  right: 20px;
}
.ruleForm {
  width: 60%;
  padding-bottom: 180px;
}
.state {
  position: absolute;
  text-align: center;
  background: #e6eeff;
  border: 1px solid #3c94f4;
  border-radius: 3px;

  padding: 8px 16px;
  right: 20px;
  color: #3c94f4;
}
</style>

